<cfcomponent output="false">


<!--- Constructor code --->
<cfset THIS.separator=getPathSeparator()>
<cfset THIS.linkSeparator = "/">

<!--- Get system path separator character --->
<cffunction name="getPathSeparator" access="private" returntype="string">
    <!--- Init variables --->
    <cfset var jifObj="">
    <!--- Need java.io.File class --->
    <cfobject type="java" class="java.io.File" name="jifObj">
    <!--- Return seperator --->
    <cfreturn jifObj.separator>
</cffunction>

<!--- Get system drives (or roots) --->
<cffunction name="getDrives" access="private" returntype="query">
    <!--- Init variables --->
    <cfset var jifObj="">
    <cfset var drives="">
    <cfset var i=0>
    <cfset var result=QueryNew("name")>

    <!--- Need java.io.File class --->
    <!---<cfobject type="java" class="java.io.File" name="jifObj">--->
    <!--- Get drives/roots --->
    <!---<cfset drives=jifObj.listRoots()>--->

    <!--- Loop through results and create query --->
    <!---<cfloop from="1" to="#ArrayLen(drives)#" index="i">
        <cfset QueryAddRow(result)>
        <cfset QuerySetCell(result, "name", drives[i].toString())>
    </cfloop>--->

	<cfdirectory directory="#ExpandPath('/pathfinder/testing')#" action="list" name="result" sort="type asc">

    <!--- Return results --->
    <cfreturn result>

</cffunction>


<!--- Get directory entries for Ajax CFTREE --->
<cffunction name="getDirEntries" access="remote" returnType="any">
    <cfargument name="path" type="string" required="false" default="">
    <cfargument name="value" type="string" required="false" default="">

    <!--- Init variables --->
    <cfset var dir="">
    <cfset var entry="">
    <cfset var result=arrayNew(1)>
    <cfset var filepath="">

    <!--- Check if top level --->
    <cfif ARGUMENTS.value IS "">
        <!--- Yes, top level, get drives(root) --->
        <cfset dir=getDrives()>
        <!--- Loop through dir list --->
        <!---<cfloop query="dir">
            <!--- Add each drive/root --->
            <cfset entry=StructNew()>
            <cfset entry.value=dir.directory & THIS.separator & dir.name>
            <cfset entry.display=dir.name>
            <cfset entry.img="fixed">
            <cfset ArrayAppend(result, entry)>
        </cfloop>--->
    <cfelse>
        <!--- Not top level, get dir list --->
        <cfdirectory action="list"
                    directory="#ARGUMENTS.value#"
                    name="dir"
                    sort="name">
	</cfif>
	<!--- Loop through dir list --->
	<cfloop query="dir">
		<!--- Create entry --->
		<cfset entry=StructNew()>

		<!--- Use full path as value --->
		<cfif arguments.value IS "">
			<cfset entry.value=dir.directory & THIS.separator & dir.name>
		<cfelse>
			<cfset entry.value=ARGUMENTS.value & THIS.separator & dir.name>
		</cfif>

		<!--- Use just name for display --->
		<cfset entry.display=dir.name>

		<!--- Is this a file or a dir? --->
		<cfif dir.type IS "file">
			<!--- A file, so no children --->
			<cfset entry.leafnode=TRUE>
			<!--- Use document icon --->
			<cfset entry.img="document">
			<!--- link to file in new tab --->
			<cfset entry.href = dir.name>
			<!---<cfset entry.href= Replace(ReplaceNoCase(dir.directory,"c:\inetpub\wwwroot\",THIS.linkSeparator),"\",THIS.linkSeparator) & THIS.linkSeparator & dir.name>--->
			<cfset entry.target="_new">
		<cfelse>
			<!--- A dir, use folder icon --->
			<cfset entry.img="folder">
			<cfset entry.imgopen="folder">
		</cfif>

		<!--- Add it to the array --->
		<cfset ArrayAppend(result, entry)>
	</cfloop>

    <!--- And return the results --->
    <cfreturn result>
</cffunction>

</cfcomponent>